# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=e-antic
pkgver=1.3.0
pkgrel=1
pkgdesc='Embedded algebraic number fields (on top of antic)'
arch=(loong64 x86_64)
url='https://github.com/flatsurf/e-antic/'
license=(LGPL)
depends=(arb antic)
makedepends=(boost catch2)
source=(https://github.com/flatsurf/e-antic/releases/download/$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('ae12cb87f09478f49c4acdf0f3ff888dc556267614c0a5a3bc8bfaa41b22deef')

prepare() {
  cd $pkgname-$pkgver
# Unbundle catch2 to fix build with glibc 2.35
  rm -r libeantic/test/external/catch2/single_include/catch2
  ln -s /usr/include/catch2 libeantic/test/external/catch2/single_include
}

build() {
  cd $pkgname-$pkgver
  ./configure \
    --prefix=/usr \
    --without-benchmark \
    --without-byexample \
    --without-pytest \
    --without-doc
# https://bugzilla.gnome.org/show_bug.cgi?id=655517
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libeantic/libtool
  make
}

check() {
  cd $pkgname-$pkgver
  make check
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install

  install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
